import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.Formatter;

public class MyLogger {
	
	Logger logger;
	boolean append = true;
	MyLogger(final String fname)
	{
		String path = "Logs/" + fname;
		try {
			FileHandler handler = new FileHandler(path,append);
			handler.setFormatter(new Formatter()
			{
				public String format(LogRecord rec)
				{
					StringBuffer buf = new StringBuffer(1000);
					buf.append(new java.util.Date());
					buf.append(' ');
					buf.append(rec.getLevel());
					buf.append(' ');
					buf.append(formatMessage(rec));
					buf.append('\n');
					return buf.toString();
				}
			});
			
			logger = Logger.getLogger("ServerLog");
			logger.addHandler(handler);
		} catch (SecurityException e1) {
			e1.printStackTrace();
		} catch (IOException e1) {
			e1.printStackTrace();
		}
	}
	void logMessage(String message)
	{
		logger.info(message);
	}

}
